/*****************************************************************
 * this program performs that it detects the properties of positive
 * and negative of a input number according to he highest bitwise
 *
 * for example:
 * input: 0xFFA7
 * output: is negative number
 *
 * date:	2016|01|15
 * author:	laishaofa@gmail.com
 *****************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int isNegative1(short num){
    return (num&0x8000);
}

int isNegative2(short num){
    return (num>>15);
}

int main(){
    int n = 0;
    char str[16] = {0};

    /* input in hex format */
    printf("Please input number(hex format,e.g 0xFFA7 or 0xffa7):");
    scanf("%hx",&n);
    if(n==0){
        printf("input is invalid!\n");
        return (-1);
    }

    printf("is %s number!\n", isNegative1(n) ? "negative":"positive");
    printf("is %s number!\n", isNegative2(n) ? "negative":"positive");
    return 0;
}
